package safari.model.common;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.mybatis.spring.SqlSessionTemplate;

import com.ibatis.sqlmap.client.SqlMapSession;

import safari.model.buy.BuyBoardVO;
import safari.model.free.FreeBoardVO;
import safari.model.sell.HotKeywordListVO;
import safari.model.sell.SellBoardVO;

public class CommonDaoImpl implements CommonDao {
	private SqlSessionTemplate sqlSessionTemplate;
	/**
	 * CommonDaoImpl 생성자
	 * SqlSessionTemplate 객체를 주입받아서 sqlSessionTemplate 사용한다.
	 */
	public CommonDaoImpl(SqlSessionTemplate sqlSessionTemplate){
		this.sqlSessionTemplate=sqlSessionTemplate;
	}
	@Override
	public List<SellBoardVO> selectSellBoardList() throws SQLException {
		Map map=new HashMap();
		map.put("contentNumberPerPage", 5);
		map.put("nowPage", 1);
		return sqlSessionTemplate.selectList("sell.selectContentList",map);
	}
	@Override
	public List<BuyBoardVO> selectBuyBoardList() throws SQLException {
		return sqlSessionTemplate.selectList("buy.getContentList",1);
	}
	@Override
	public List<FreeBoardVO> selectFreeBoardList() throws SQLException {
		return sqlSessionTemplate.selectList("free.freeBoardGetAllList",1);
	}
	@Override
	public List<HotKeywordListVO> selectHotKeywordList() throws SQLException {
		return sqlSessionTemplate.selectList("sell.selectHotKeywordList");
	}
	/**
	 * 가장 많이 조회한 게시판을 보여주는 메서드
	 */
	@Override
	public List<SellBoardVO> selectHotClickList() throws SQLException {
		return sqlSessionTemplate.selectList("sell.selectHotClickList");
	}

}
